<?php
session_start();
include("./conn/conn.php");
if ($_SESSION['name'] == "") {
  echo("<script>alert('请先登陆！');window.location.href='dlym.php';</script>");
}
header("content-type:text/html;charset=utf-8");
$name = $_GET['id'];
$namea = $_SESSION['name'];
$da = $_SESSION['da'];
$te = $_SESSION['te'];
$shi = '是';
$fo = '否';
$sql_cx = "select * from tb_hydl where account='$namea'";
echo $namea;
$reslut_cx = mysqli_query($link, $sql_cx);
if (mysqli_num_rows($reslut_cx) > 0) {
  $rows = mysqli_fetch_assoc($reslut_cx);
  $en = $rows[identity];
  $to = $rows[contact];
  $na = $rows['name'];
  $reslut_user = mysqli_query($link, "update tb_room set state=1 where `name`='" . $name . "'");
  if ($reslut_user) {
    $sql_ly = "insert into tb_ydxt(intime,extime,people,name,contact,identity,whether,compcete) 		values('$da','$te','$na','$name','$to','$en','$fo','$shi')";
    if (mysqli_query($link, $sql_ly)) {
      echo("<script>alert('预定成功，期待您的入住！');window.location.href='sy.php';</script>");
    } else {
      echo("<script>alert('预定失败请重试！');window.location.href='kfyd.php';</script>");
    }
  } else {
  }
} else {
  echo '数据库链接失败';
}
?> 
